﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Moria.Common.Model;
using Redbrick.Silverlight.Common;
using Moria.Common;

namespace Moria.Silverlight.Controls
{
	public partial class StoreDialog : ChildWindow
	{

		bool _haggleInProgress = false;

		public StoreDialog()
		{
			Loaded += new RoutedEventHandler(StoreDialog_Loaded);
			InitializeComponent();
		}

		void StoreDialog_Loaded(object sender, RoutedEventArgs e)
		{
			if (this.store != null)
			{
				this.Title = store.Type.Description() + " Inventory";
				
			}
		}

		private void OKButton_Click(object sender, RoutedEventArgs e)
		{
			this.DialogResult = true;
		}
		private void BuyButton_Click(object sender, RoutedEventArgs e)
		{

		}
	
        private void SelectedItemChanged(object sender, SelectionChangedEventArgs e)
		{
            if (e.AddedItems != null && e.AddedItems.Count > 0)
            {
                InventoryRecord record = e.AddedItems[0] as InventoryRecord;
                InventoryItem itm = new InventoryItem(record);
                itm.ItemCount = 1;
                this.store.CurrentItem = new InventoryRecord() { InventoryItem = itm,BaseCost=record.BaseCost,AdjustedCost=record.AdjustedCost };
            }
            else
            {
                this.store.CurrentItem = null;
            }
		
		}

	
		
		private Store store { get { return this.DataContext as Store; } }


	}
}

